package com.lz.ccjdemo.greendao.data;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToMany;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import com.lz.ccjdemo.greendao.dao.DaoSession;
import com.lz.ccjdemo.greendao.dao.OperationProcessDataDao;
import com.lz.ccjdemo.greendao.dao.WarehouseDataDao;
import com.lz.ccjdemo.greendao.dao.DishDataDao;

import java.util.List;

@Entity
public class DishData {
    //设置id  是否自增
    @Id(autoincrement = true)
    public Long id;

    //菜品名称
    public String dish_name;

    //仓库名称
    @ToMany(referencedJoinProperty = "dish_id")
    public List<WarehouseData> warehouse;

    //操作步骤
    @ToMany(referencedJoinProperty = "dish_id")
    public List<OperationProcessData> processData;


    /**
     * 预留字段
     */
    public String  des;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 1387819719)
    private transient DishDataDao myDao;


    @Generated(hash = 1460180402)
    public DishData(Long id, String dish_name, String des) {
        this.id = id;
        this.dish_name = dish_name;
        this.des = des;
    }


    @Generated(hash = 1190291149)
    public DishData() {
    }


    public Long getId() {
        return this.id;
    }


    public void setId(Long id) {
        this.id = id;
    }


    public String getDish_name() {
        return this.dish_name;
    }


    public void setDish_name(String dish_name) {
        this.dish_name = dish_name;
    }


    public String getDes() {
        return this.des;
    }


    public void setDes(String des) {
        this.des = des;
    }


    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 1432714424)
    public List<WarehouseData> getWarehouse() {
        if (warehouse == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            WarehouseDataDao targetDao = daoSession.getWarehouseDataDao();
            List<WarehouseData> warehouseNew = targetDao._queryDishData_Warehouse(id);
            synchronized (this) {
                if (warehouse == null) {
                    warehouse = warehouseNew;
                }
            }
        }
        return warehouse;
    }


    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 179851184)
    public List<OperationProcessData> getProcessData() {
        if (processData == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            OperationProcessDataDao targetDao = daoSession.getOperationProcessDataDao();
            List<OperationProcessData> processDataNew = targetDao
                    ._queryDishData_ProcessData(id);
            synchronized (this) {
                if (processData == null) {
                    processData = processDataNew;
                }
            }
        }
        return processData;
    }


    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }


    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }


    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }


    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1549041086)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getDishDataDao() : null;
    }


    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 904700445)
    public synchronized void resetWarehouse() {
        warehouse = null;
    }


    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 814725448)
    public synchronized void resetProcessData() {
        processData = null;
    }



}
